package com.jihox.abookpro.view;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import com.jihox.abookpro.R;

public class JHProgressDialog extends AlertDialog  {

	Activity mParentActivity;
	
	public JHProgressDialog(Context context, int theme) {
		super(context,theme);
		mParentActivity = (Activity)context;
	}
	TextView textView;
	static String progressMessage = "";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_progress);
		textView = (TextView) findViewById(R.id.progressText);
		textView.setText(progressMessage);
		this.setCanceledOnTouchOutside(false);
	}
	

	public static JHProgressDialog show(Context context, CharSequence title, CharSequence message) {
		progressMessage = (String) message;
		JHProgressDialog dialog = new JHProgressDialog(context,R.style.JHProgressDialog);
        dialog.show();
        return dialog;
	}
	
	@Override
    public void dismiss()
    {
        if (mParentActivity != null && !mParentActivity.isFinishing())
        {
            super.dismiss();    //调用超类对应方法
        }
    }
}
